﻿<%@ Page Title="Manage Translations &raquo; ResourceBlender" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="TranslationsOnline.aspx.cs" Inherits="Translations" EnableEventValidation="false" %>
<%@ MasterType VirtualPath="~/MasterPage.master" %>

<asp:Content ID="contentHead" ContentPlaceHolderID="head" Runat="Server">
    <link rel="Stylesheet" type="text/css" href="css/spreadsheet.css" />
    <!--[if IE]>
    <link rel="Stylesheet" type="text/css" href="css/ie-spreadsheet.css" />
    <![endif]-->
</asp:Content>
<asp:Content ID="contentMain" ContentPlaceHolderID="cntMain" Runat="Server">
    <asp:ScriptManager ID="scrUpdateLanguages" runat="server"></asp:ScriptManager>
        <asp:MultiView ID="mltMain" runat="server" ActiveViewIndex="0">
            <asp:View ID="viwNoApps" runat="server">
                <h1><asp:Label ID="lblManageTranslationsHeading" runat="server" Text="Manage Translations"></asp:Label></h1>
                <p>You must <asp:HyperLink ID="lnkAddApplication" runat="server" Text="add an application" NavigateUrl="~/Applications.aspx">add an application</asp:HyperLink> before generating resources.</p>
            </asp:View>
            <asp:View ID="viwSelectTranslations" runat="server">
                <h1><asp:Label ID="lblSelectTranslationsHeading" runat="server" Text="Manage Translations"></asp:Label></h1>
                <div class="niceform">
                    <fieldset>
                        <legend>Select Components</legend>
                        <div class="formrow block threecol">
                            <asp:UpdatePanel ID="updRadApplication" runat="server" UpdateMode="Conditional">
                                <ContentTemplate>
                                    <div class="formcol">
                                        <label class="block">Application</label>
                                        <asp:RadioButtonList ID="radApplication" runat="server" RepeatLayout="Flow" 
                                            onselectedindexchanged="ShowLanguages" 
                                            AutoPostBack="True" CssClass="checks applicationChecks plain"></asp:RadioButtonList>
                                    </div>
                                    <div class="formcol">
                                        <asp:Label ID="lblBundleName" runat="server" Text="Bundles" 
                                            AssociatedControlID="lstBundles" CssClass="block"></asp:Label>
                                        <asp:ListBox ID="lstBundles" runat="server" SelectionMode="Multiple" 
                                            Rows="10" Width="100%"></asp:ListBox>
                                    </div>
                                    <div class="formcol">
                                        <label class="block">Languages</label>
                                        <asp:ListBox ID="lstLanguages" runat="server" SelectionMode="Multiple" 
                                            Rows="10" Width="100%"></asp:ListBox>
                                        <asp:RequiredFieldValidator ID="vldLanguages" ControlToValidate="lstLanguages" runat="server" ErrorMessage="At least one language must be selected"></asp:RequiredFieldValidator>
                                    </div>
                                    <asp:UpdateProgress ID="prgRadApplication" runat="server" 
                                        AssociatedUpdatePanelID="updRadApplication" 
                                        DisplayAfter="100">
                                        <ProgressTemplate>
                                            <div class="centered"><asp:Image ID="imgLoadingLanguagesSelection" runat="server" ImageUrl="~/images/ajax-loader.gif" AlternateText="Loading Languages..." /></div>
                                        </ProgressTemplate>
                                    </asp:UpdateProgress>
                                </ContentTemplate>
                            <Triggers>
                                <asp:AsyncPostBackTrigger ControlID="radApplication"
                                    EventName="SelectedIndexChanged" />
                            </Triggers>
                        </asp:UpdatePanel>
                    </div>
                    <div class="clear">&nbsp;</div>
                    </fieldset>
                    <div class="actions">
                        <asp:Button ID="btnEditTranslations" runat="server" Text="Edit Translations Online" 
                            OnClick="btnEditTranslations_Click" />
                    </div>
                </div>
            </asp:View>
            <asp:View ID="viwManageTranslations" runat="server">
                <asp:SqlDataSource ID="dsMain" runat="server"
                     ConnectionString="<%$ ConnectionStrings:Default %>"
                     ProviderName="<%$ ConnectionStrings:Default.ProviderName %>"
                     >
                </asp:SqlDataSource>
                <asp:SqlDataSource ID="dsBundles" runat="server"
                     ConnectionString="<%$ ConnectionStrings:Default %>"
                     ProviderName="<%$ ConnectionStrings:Default.ProviderName %>"
                     >
                </asp:SqlDataSource>
                <div id="fullsizeholder" class="ssFullSize" runat="server">
                    <h1><asp:Label ID="lblEditingTranslationsFor" runat="server" Text="formatted text"></asp:Label></h1>
                    <div style="float:left">
                        <asp:UpdateProgress ID="upgGrdTranslations" runat="server" 
                                            AssociatedUpdatePanelID="updGrdTranslations" 
                                            DisplayAfter="100">
                            <ProgressTemplate>
                                <div class="centered"><asp:Image ID="imgLoadingTranslation" runat="server" ImageUrl="~/images/ajax-loader.gif" AlternateText="Loading..." /></div>
                            </ProgressTemplate>
                        </asp:UpdateProgress>
                    </div>
                    <div id="inlinenav">
                        <asp:LinkButton ID="lnkExpandScreen" runat="server" CssClass="lnkContract" 
                            OnClientClick="return toggleFullWindow(this);" 
                            onclick="lnkExpandScreen_Click" CausesValidation="False" 
                            EnableViewState="False">Contract to normal size</asp:LinkButton>
                        <ul>
                            <li><a class="navApplications" id="lnkApplications" href="~/Applications.aspx" runat="server" title="Applications">Applications</a></li>
                            <li><a class="navTranslations" id="lnkTranslations" href="~/Translations.aspx" runat="server" title="Translations">Translations</a></li>
                            <li><a class="navGenerate" id="lnkGenerate" href="~/Generate.aspx" runat="server" title="Generate">Generate</a></li>
                            <li><a class="navImport" id="lnkImport" href="~/Import.aspx" runat="server" title="Import">Import</a></li>
                            <li><a class="navHelp" href="http://wiki.lime49.com/index.php?title=ResourceBlender" title="Help">Help</a></li>
                            <li><a class="navBackup" id="lnkBackup" href="~/Backup.aspx" runat="server" title="Backup &amp; Restore">Backup &amp; Restore</a></li>
                            <li><a class="navSettings" id="lnkSettings" href="~/Settings.aspx" runat="server" title="Settings">Settings</a></li>
                        </ul>
                    </div>
                    <div class="clear"></div>
                    <asp:UpdatePanel ID="updGrdTranslations" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                            <asp:GridView ID="grdTranslations" runat="server" AllowPaging="True" 
                                AllowSorting="True" AutoGenerateColumns="true" CssClass="nicetable" 
                                Width="100%" DataKeyNames="applicationid,bundle,elementname"
                                OnRowDatabound="row_DataBound" 
                                OnRowCommand="grd_RowCommand" 
                                OnPageIndexChanging="grd_PageIndexChanging"
                                OnSorting="grd_Sorting"
                                OnPreRender="grd_PreRender"
                                PageSize="15">
                                <PagerSettings PageButtonCount="8" Mode="NumericFirstLast" Position="TopAndBottom" />
                                <Columns>
                                    <asp:TemplateField>
                                        <ItemTemplate>
                                            <%# Container.DataItemIndex +1 %>
                                        </ItemTemplate>
                                        <ItemStyle CssClass="ssRowLabel" HorizontalAlign="Center" />
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Bundle" SortExpression="bundlename">
                                        <ItemTemplate>
                                            <asp:MultiView ID="mltBundle" runat="server" ActiveViewIndex="0">
                                                <asp:View ID="viwShowBundle" runat="server">
                                                    <asp:Label ID="lblBundleName" runat="server" Text='<%# Eval("bundlename") %>'></asp:Label>
                                                </asp:View>
                                                <asp:View ID="viwEditBundle" runat="server">
                                                    <asp:DropDownList ID="cboBundleName"  runat="server" ValidationGroup="editelement" DataSourceID="dsBundles" DataTextField="name" DataValueField="id"></asp:DropDownList>
                                                </asp:View>
                                            </asp:MultiView>
                                        </ItemTemplate>
                                        <ItemStyle CssClass="ssCell" />
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Element" SortExpression="elementname">
                                        <ItemTemplate>
                                            <asp:MultiView ID="mltElement" runat="server" ActiveViewIndex="0">
                                                <asp:View ID="viwShowElement" runat="server">
                                                    <asp:Label ID="lblElementName" runat="server" Text='<%# Eval("elementname") %>' EnableViewState="False"></asp:Label>
                                                </asp:View>
                                                <asp:View ID="viwEditElement" runat="server">
                                                    <asp:Label ID="lblElementNameDesc" runat="server" Text="Element Name" AssociatedControlID="txtElementName" EnableViewState="False"></asp:Label>
                                                    <br />
                                                    <asp:TextBox ID="txtElementName" runat="server" Text='<%# Eval("elementname") %>' EnableViewState="False" ValidationGroup="editelement"></asp:TextBox>
                                                    <br />
                                                    <asp:Label ID="lblElementComment" runat="server" Text="Comment" AssociatedControlID="txtElementComment" EnableViewState="False"></asp:Label>
                                                    <br />
                                                    <asp:TextBox ID="txtElementComment" runat="server" Text='<%# Eval("elementcomment") %>' TextMode="MultiLine" EnableViewState="False" ValidationGroup="editelement"></asp:TextBox>
                                                    <br />
                                                    <asp:RequiredFieldValidator SetFocusOnError="true" Display="Dynamic"
                                                    ID="vldEditElementName" runat="server" ErrorMessage="Element name must be entered" ControlToValidate="txtElementName" ValidationGroup="editelement"></asp:RequiredFieldValidator>
                                                </asp:View>
                                            </asp:MultiView>
                                        </ItemTemplate>
                                        <ItemStyle CssClass="ssCell" />
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Edit">
                                        <ItemTemplate>
                                            <asp:MultiView ID="mltActions" runat="server" ActiveViewIndex="0">
                                                <asp:View ID="viwEdit" runat="server">
                                                    <div class="centered">
                                                        <asp:ImageButton ID="btnEdit" runat="server" 
                                                            AlternateText='<%# "Edit " + Eval("elementname") %>' 
                                                            EnableViewState="False"
                                                            CommandName="edittranslation" 
                                                            ImageUrl="~/images/edit.png" />
                                                    </div>
                                                </asp:View>
                                                <asp:View ID="viwSave" runat="server">
                                                    <asp:Label ID="lblTranslationIdDesc" runat="server" Text="Translation ID" EnableViewState="False" AssociatedControlID="cboTranslationID"></asp:Label>
                                                    <br />
                                                    <asp:DropDownList ID="cboTranslationID" runat="server" ValidationGroup="editelement">
                                                    </asp:DropDownList>
                                                    <asp:Label ID="lblTranslationId" runat="server" Text='<%# Eval("translationid") %>' EnableViewState="False" Visible="false"></asp:Label><%-- used to bind the combobox selected index --%>
                                                    <br />
                                                    <asp:Button ID="btnChangeTranslation"  Visible="false" runat="server" Text="Change Translation" CommandName="changetranslation" EnableViewState="False" />
                                                    <asp:Label ID="lblError" runat="server" Text="" CssClass="error"></asp:Label>
                                                    <asp:Label ID="lblTranslationComment" runat="server" Text="Comment" AssociatedControlID="txtTranslationComment" EnableViewState="False"></asp:Label>
                                                    <br />
                                                    <asp:TextBox ID="txtTranslationComment" runat="server" Text='<%# Eval("translationcomment") %>' TextMode="MultiLine" EnableViewState="False" ValidationGroup="editelement"></asp:TextBox>
                                                    <br />
                                                    <asp:Button ID="btnDeleteElement" runat="server" Text="Delete Element" CommandName="deleteelement" CommandArgument='<%# Eval("id") %>' ValidationGroup="editelement" />
                                                    <asp:Button ID="btnSave" runat="server" Text="Save" CommandName="savetranslation" CommandArgument='<%# Eval("id") %>' ValidationGroup="editelement" />
                                                </asp:View>
                                            </asp:MultiView>
                                        </ItemTemplate>
                                        <ItemStyle CssClass="ssCell" />
                                    </asp:TemplateField>
                                </Columns>
                                <HeaderStyle CssClass="excelHead" />
                                <RowStyle CssClass="even" />
                                <AlternatingRowStyle CssClass="alt" />
                                <PagerStyle CssClass="pager" />
                                <EmptyDataTemplate>
                                No translations
                                </EmptyDataTemplate>
                            </asp:GridView>
                            <div class="niceform">
                                <fieldset style="background: #ededff;">
                                    <legend>Add Element</legend>
                                    <fieldset>
                                            <legend>Element</legend>
                                            <div class="formrow block">
                                                <asp:Label ID="lblAddBundleName" runat="server" AssociatedControlID="cboAddBundleName" 
                                                    Text="Bundle Name"></asp:Label>
                                                <asp:DropDownList ID="cboAddBundleName" runat="server" ValidationGroup="addelement" DataSourceID="dsBundles" DataTextField="name" DataValueField="id">
                                                </asp:DropDownList>
                                            </div>
                                            <div class="formrow block">
                                                <asp:Label ID="lblAddElementName" runat="server" AssociatedControlID="txtAddElementName"
                                                    Text="Element Name"></asp:Label>
                                                <asp:TextBox ID="txtAddElementName" runat="server" EnableViewState="false" ValidationGroup="addelement"></asp:TextBox>
                                                <asp:Label ID="lblAddError" runat="server" CssClass="error" Visible="false"></asp:Label>
                                                <asp:RequiredFieldValidator SetFocusOnError="true"
                                                    ID="vldAddElementName" runat="server" ErrorMessage="Element name must be entered" ControlToValidate="txtAddElementName" ValidationGroup="addelement"></asp:RequiredFieldValidator>
                                            </div>
                                            <div class="formrow block">
                                                <asp:Label ID="lblAddElementComment" runat="server" Text="Element Comment" ToolTip="Notes about the element's location"  AssociatedControlID="txtAddElementComment" EnableViewState="False"></asp:Label>
                                                <asp:TextBox ID="txtAddElementComment" runat="server" TextMode="MultiLine" ValidationGroup="addelement"></asp:TextBox>
                                            </div>
                                        </fieldset>
                                    <fieldset>
                                            <legend>Translation</legend>
                                            <div class="formrow block">
                                                <asp:Label ID="lblAddTranslationID" runat="server" Text="Translation ID" AssociatedControlID="cboAddTranslationID" EnableViewState="False"></asp:Label>
                                                <asp:DropDownList ID="cboAddTranslationId" runat="server" AutoPostBack="true"
                                                    OnSelectedIndexChanged="ChangeAddDisplayedTranslation" ValidationGroup="addelement">
                                                </asp:DropDownList>
                                            </div>
                                            <div class="formrow block">
                                                <asp:Label ID="lblAddTranslationComment" runat="server" Text="Translation Comment" ToolTip="Contextual information about the translation" AssociatedControlID="txtAddTranslationComment" EnableViewState="False"></asp:Label>
                                                <asp:TextBox ID="txtAddTranslationComment" runat="server" TextMode="MultiLine" EnableViewState="False" ValidationGroup="addelement"></asp:TextBox>
                                            </div>
                                            <asp:table id="tblAddTranslation" CssClass="addtranslation" runat="server">
                                                <asp:TableHeaderRow Visible="false">
                                                    <asp:TableHeaderCell>Language</asp:TableHeaderCell>
                                                    <asp:TableHeaderCell>Translation</asp:TableHeaderCell>
                                                    <asp:TableHeaderCell>Actions</asp:TableHeaderCell>
                                                </asp:TableHeaderRow>
                                            </asp:table>
                                            <div class="formrow block">
                                                <asp:Button ID="btnAddElement" runat="server" Text="Add Element" 
                                                    CssClass="uniformbutton" EnableViewState="False" 
                                                    OnClick="btnAddElement_Click" ValidationGroup="addelement" />
                                            </div>
                                        </fieldset>
                                </fieldset>
                            </div><!--add form-->
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </div><!--fullsizeholder-->
            </asp:View>
        </asp:MultiView>
</asp:Content>

